package com.itheima.job;

import java.util.ArrayList;
import java.util.Iterator;

public class Test01 {
    public static void main(String[] args) {
        ArrayList<Integer> arrayList = new ArrayList<>();
        arrayList.add(1);
        arrayList.add(2);
        arrayList.add(3);
        arrayList.add(4);

        //方式一：普通for
        for (int i = 0; i < arrayList.size(); i++) {
            Integer value = arrayList.get(i);
            System.out.print(value + " ");
        }
        System.out.println();
        System.out.println("----------------------");

        //方式二：迭代器
        Iterator<Integer> it = arrayList.iterator();
        while (it.hasNext()){
            Integer itValue = it.next();
            System.out.print(itValue+" ");
        }
        System.out.println();
        System.out.println("----------------------");

        //方式三：增强for
        for (Integer integer : arrayList) {
            System.out.print(integer+" ");
        }
    }
}
